<template>
  <div class="tijian-wrapper-v2">
    <div class="sub-banner">
      <!-- <img :src="`${staticPath}/img_hulidaojia@2x.png`" alt=""> -->
      <van-swipe
        vertical
        class="huli-wrapper"
        :autoplay="3000"
        :show-indicators="false"
      >
        <van-swipe-item
          v-for="(item, index) in bannerList.subscribe.poster"
          :key="index"
          @click="$router.push({ path: '/huli/index' })"
        >
          <img :src="item.picurl" alt="" srcset="" />
        </van-swipe-item>
      </van-swipe>
    </div>
    <div class="service-panel">
      <div class="huli-common-title">
        <h3 class="service-title">服务分类</h3>
        <div class="entry-list">
          <van-grid :column-num="5" :border="false">
            <van-grid-item
              :icon="item.picurl"
              :text="item.name"
              v-for="(item, index) in entryList"
              :key="index"
              @click="handleFilter(item)"
            />
          </van-grid>
        </div>
      </div>
    </div>
      <div class="service-item" v-if="checkList.length > 0">
        <van-cell
        is-link
        value="更多"
        style="padding-left: 15px; padding-right: 15px"
      >
        <template #title>
          <div class="custom-title">
            <h3>热门推荐</h3>
            /<span class="upper-letter">service items</span>
          </div>
        </template>
      </van-cell>
        <div class="items-wrapper">
          <div
            class="pic-wrapper"
            v-for="(item, index) in checkList"
            :key="index"
            @click="
              () => $router.push({ path: `/user/medical/detail/${item.id}` })
            "
          >
             <div class="pic-img">
              <img :src="item.picurl[0]" alt="" srcset="" style="height: 100px" />
             </div>
            <div class="thrunmb">
              <div class="left">
                <p class="title">{{ item.name }}</p>
                <div class="flex-desc">
                  {{ item.abstract }}
                </div>
              </div>
              <div class="right">
                <em>￥</em>{{ item.price }}<em>元</em>
                <span class="line-price">￥{{ item.lineation }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>

      <van-empty description="暂无数据" v-else />

      <div class="fixed-bottom">
        <van-pagination
          v-model="currentPage"
          :page-count="pageCount"
          @change="handlePage"
          mode="simple"
        />
      </div>
    </div>
</template>

<script>
import { checksListServer, checksTypeServer } from "@/service/server";
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      currentPage: 1,
      staticPath: process.env.VUE_APP_STATIC_PATH,
      checkList: [],
      pageCount: 0,
      entryList: [],
    };
  },
  created() {
    let params = {
      pageNum: 1,
      expand: "comment",
    };
    this.queryCheckList(params);
    this.getServerList();
  },
  computed: {
    ...mapGetters(["bannerList"]),
  },
  methods: {
    handleFilter(item) {
      let params = {
        pageNum: 1,
        expand: "comment",
        type: item.id,
      };
      this.queryCheckList(params);
    },
    handlePage(e) {
      this.currentPage = e;
    },
    async getServerList() {
      let result = await checksTypeServer();
      if (result.status == 200) {
        this.entryList = result.data;
      } else {
        this.$toast(result.message);
      }
    },
    async queryCheckList(params) {
      let result = await checksListServer(params);
      if (result.status == 200) {
        this.checkList = result.data.model;
        if (result.data.model.length > 0) {
          this.pageCount = result.data._meta.pageCount;
        }
      } else {
        this.$toast(result.message);
      }
    },
  },
  components: {},
};
</script>

<style lang="less">
@import "~@/assets/less/mixin.less";
.fixed-bottom {
  width: 100%;
  // position: fixed;
  bottom: 70px;
  padding: 10px;
  padding-bottom: 60px;
}
.sub-banner {
  width: 100%;
  height: 150px;
}
img {
  width: 100%;
}

.service-item {
    margin-top: 10px;
    background: #fff;
    .custom-title {
      display: flex;
      justify-content: flex-start;
      font-size: 16px;
      color: #000;
    }
    .van-cell__value {
      font-size: 13px;
      flex: none;
    }
  }
  
  .line-price{
    font-size: 12px;
    color: #999;
    text-decoration: line-through;
  }
.tijian-wrapper-v2 {
  background: #f5f5f5;
  .van-grid-item__content,
  .van-cell {
    background: #f8f8f8;
    padding-left: 0;
    padding-right: 0;
  }
  .service-panel {
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    position: relative;
    z-index: 1;
    margin-top: -10px;
    padding: 15px 15px 0;
    background: #f8f8f8;
    .service-title {
      font-size: 16px;
      color: #000;
      padding: 0 10px;
    }
  }
  .items-wrapper {
    padding: 12px 15px;
    position: relative;
     &::after{
      content: '';
      position: absolute;
      box-sizing: border-box;
      pointer-events: none;
      right: 16px;
      bottom: 0;
      left: 16px;
      border-bottom: 1px solid #ebedf0;
      -webkit-transform: scaleY(0.5);
      transform: scaleY(0.5);
    }
    .pic-wrapper {
      border-radius: 10px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 10px 0;
      .pic-img {
        width: 120px;
        min-height: 60px;
        img {
          width: 120px;
          height: 100px !important;
        }
      }
    }

    .thrunmb {
      flex: 1;
      display: flex;
      justify-content: space-around;
      align-items: flex-start;
      flex-direction: column;
      padding: 0 10px;
      height: 100px;
      .left {
        flex: 1;
        display: flex;
        justify-content: flex-start;
        align-items: flex-start;
        flex-direction: column;
        .title {
          font-size: 16px;
          color: #000;
          .ellipsisLine(1);
        }
        .flex-desc {
          padding-top: 6px;
          height: 25px;
          line-height: 25px;
          color: #999;
          .ellipsisLine(1);
        }
      }
      .right {
        color: #e02e2e;
        font-size: 18px;
        i {
          font-size: 13px;
        }
      }
    }
  }
  //   .items-wrapper{
  //   padding: 15px 0;
  //   display: flex;
  //   justify-content: flex-start;
  //   align-items: center;
  //   flex-wrap: wrap;
  //   .pic-wrapper{
  //     width: 48%;
  //     flex-basis: 48%;
  //     background: #fff;
  //     border-radius: 10px;
  //     img{
  //       width: 100%;
  //       height: 150px;
  //     }
  //     margin-right: 4%;
  //     margin-bottom: 12px;
  //     &:nth-child(2n){
  //       margin-right: 0;
  //     }
  //   }

  //   .thrunmb{
  //     display: flex;
  //     justify-content: space-around;
  //     align-items: center;
  //     flex-direction: column;
  //     padding: 14px 10px;
  //     .top{
  //       flex: 1;
  //       display: flex;
  //       justify-content: space-around;
  //       align-items: flex-start;
  //       flex-direction: column;
  //       margin-bottom: 12px;
  //       .title{
  //         font-size: 16px;
  //         color: #000;
  //         margin-bottom: 5px;
  //       }
  //       .flex-desc{
  //         height: 44px;
  //         padding-top: 6px;
  //         color: #999;
  //         line-height: 1.5;
  //         .ellipsisLine(2)
  //       }
  //     }
  //     .bottom{
  //       color: #E02E2E;
  //       font-size: 18px;
  //       display: flex;
  //       align-items: flex-end;
  //       width: 100%;
  //       justify-content: flex-start;
  //       i{
  //         font-size: 13px;
  //       }
  //       .line-price{
  //         color: #999;
  //         font-size: 13px;
  //         margin-left: 6px;
  //       }
  //     }
  //   }
  // }
  .huli-common-title {
    margin-bottom: 15px;
    .right-arrow {
      display: flex;
      justify-content: flex-end;
      color: #999;
      font-size: 13px;
      flex: 1;
    }
    h3 {
      font-size: 16px;
      margin-bottom: 15px;
      display: flex;
      justify-content: flex-start;
      align-items: center;
      em {
        display: inline-block;
        width: 5px;
        height: 17px;
        background: linear-gradient(0deg, #fcc9cb, #f7757b);
        border-radius: 5px;
        margin-right: 6px;
      }
    }
  }
}
</style>